﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BLL;
namespace 健身房管理
{
    public partial class mAdd : Form
    {
        Point mouseOff;//鼠标移动位置变量
        bool leftFlag;//标签是否为左键

        huiyuanBLL hbl = new huiyuanBLL();
        public mAdd()
        {
            InitializeComponent();
        }

        private void guna2Button1_Click(object sender, EventArgs e)
        {
            // --姓名
            //   --邮箱
            //   --性别
            //      --加入时间
            //--开卡数量
            //--开通天数
            //   --会员积分

            string name = txtname.Text;
            string mail = txtmail.Text;
            string sex = txtsex.Text;
            string qinjia = mqingja.Text;
            int carnum = int.Parse(txtcarnum.Text);
            int cartime = int.Parse(txtcartime.Text);
            int jf = carnum * cartime*10;

            Random ran = new Random();
            System.Random a = new Random(System.DateTime.Now.Millisecond);
            int RandKey = a.Next(100000);
            bool b1 = hbl.hyadd(name, mail, sex, qinjia, carnum, cartime, jf,RandKey);
            if (b1)
            {
                MessageBox.Show("添加成功");
            }
            else
            {
                MessageBox.Show("添加失败");
            }
        }

        private void guna2Button3_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void mAdd_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                mouseOff = new Point(-e.X, -e.Y);
                leftFlag = true;
            }
        }

        private void mAdd_MouseMove(object sender, MouseEventArgs e)
        {
            if (leftFlag)
            {
                Point mouseSet = Control.MousePosition;
                mouseSet.Offset(mouseOff.X, mouseOff.Y);//设置移动后的位置
                Location = mouseSet;
            }
        }

        private void mAdd_MouseUp(object sender, MouseEventArgs e)
        {
            if (leftFlag)
            {
                leftFlag = false;//释放鼠标后标注为False
            }
        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void mAdd_Load(object sender, EventArgs e)
        {

        }
    }
    
}      
